package com.lyn.solitude_plugin_host.stack;

import com.lyn.solitude_plugin_api.entity.Plugin;
import java.util.Stack;

/**
 * 插件mate栈
 *
 * @author longyn 2024/4/21
 * @version 1.0.0
 */
public class PluginStack {

    private static final Stack<Plugin> pluginStack = new Stack<>();


    public static void push(Plugin plugin) {
        pluginStack.push(plugin);
    }

    public static void pop() {
        if (pluginStack.isEmpty()) {
            return;
        }
        pluginStack.pop();
    }

    public static Plugin peek() {
        if (pluginStack.isEmpty()) {
            return null;
        }
        return pluginStack.peek();
    }


    public static void remove(String id){
        pluginStack.removeIf(plugin -> plugin.id.equals(id));
    }
}
